package com.net.controller;
  
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.swing.text.html.HTML;

import com.net.service.BaseService;
import com.net.service.UserServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.servlet.ModelAndView;
  
import com.net.domain.User;
import com.net.service.UserService;

import java.util.List;
import java.util.Map;

/** 
 * 功能概要：UserController 
 * @author zhang yufei
 * @since  2015年9月28日  
 */  
@Controller
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserServiceImpl userService;
    @Autowired
    private BaseService baseService;
      
    @RequestMapping("/user1")
    public ModelAndView getIndex(){      
        ModelAndView mav = new ModelAndView("index");   
        User user = userService.selectUserById(1);
        mav.addObject("user", user);
        return mav;    
    }

    @ResponseBody
    @RequestMapping("/user2")
    public List<Map<String,Object>> select(HttpServletRequest request, HttpServletResponse response){
        return baseService.select();
    }

    @RequestMapping("/user3")
    public String user3(HttpServletRequest request, HttpServletResponse response, ModelMap map){
        User user = userService.selectUserById(1);
        map.put("user", user);
        return "user3";
    }



}  